package com.tanhua.bg.login.config;


import com.tanhua.bg.login.pojo.Login;

/**
 * 通过ThreadLocal的形式，存储用户的数据
 */
public class LoginThreadLocal {

    private static final ThreadLocal<Login> userLogins = new ThreadLocal<>();

    private LoginThreadLocal(){}
    //向当前线程存储数据
    public static void set(Login login) {
        userLogins.set(login);
    }

    //从当前线程获取数据
    public static Login get() {
        return userLogins.get();
    }
        //从当前线程删除数据
    public static void remove() {
        userLogins.remove();
    }

    //获取当前用户的id
   /* public static Long getUserId() {
        return userLogins.get().getId();
    }*/
}
